﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;

namespace TreeBuilder
{
	public class CreateNodeAction : TreeOperationAction
	{
		private readonly INode _node;
		private Point _destination;

		public CreateNodeAction(DottedCanvas canvas, INode node, Point destination)
			:base(canvas)
		{
			_node = node;
			_destination = destination;
		}

		public override void Execute()
		{
			AddToTree((UIElement) _node);

			var moveToInitAction = new MoveNodeAction(_node, _destination);
			moveToInitAction.Execute();
			((UIElement) _node).Visibility = Visibility.Visible;
		}

		public override void Undo()
		{
			RemoveFromTree((UIElement)_node);
		}
	}
}
